import Vue from 'vue';
import Vuex from 'vuex';
import getters from './getters';
//子模块
import userInfo from './modules/userInfo';
import map from './modules/map';
import share from './modules/share';
import { getToken, setToken } from '@/utils/index';

Vue.use(Vuex);

//全局store
const state = () => ({});
const mutations = {};
const actions = {
	clearLoginInfo({ commit }) {
		setToken('');
		commit('userInfo/set_user_info', {});
	},
	logout({ dispatch, commit }) {
		dispatch('clearLoginInfo');
	},
};

export default new Vuex.Store({
	state,
	mutations,
	actions,
	getters,
	modules: {
		userInfo,
		map,
		share,
	},
});
